<meta title="用户登录" width="500px" />
<form role="form" id="loginForm" s="valid,form" s-form="{done:submitDone, action:loginAction}" method="post" style="padding: 20px;" >
    <div class="form-group" s-valid-role="item">
        <div class="input-group input-group-lg">
            <span class="input-group-addon"><span class="fa fa-user"></span></span>
            <input value="admin" type="text" name="account" id="account" class="form-control" placeholder="输入用户名" s-valid-error="require()">
        </div>
    </div>
    <div class="form-group" s-valid-role="item">
        <div class="input-group input-group-lg">
            <span class="input-group-addon"><span class="fa fa-lock"></span></span>
            <input value="admin" type="password" name="password" id="password" class="form-control" placeholder="输入密码" s-valid-error="require()" >
        </div>
    </div>
    <div class="form-group">
        <input type="submit" value="登 录" class="btn btn-lg btn-success" style="width: 100%" />
    </div>
</form>
<script>
    function submitDone(rs) {
        if (rs.code==200) {
            localStorage.adminName=rs.bean.user.name
            S.close(rs);
        } else {
            S.alert(rs.msg).done(function(){
                S.N("#account").focus();
            });
        }
    }
    function loginAction(){
        var deferred = $.Deferred();
        S.post("/api/admin/login",{"name":S.N("#account").val(),"pwd":S.N("#password").val()}).done(function (rs) {return deferred.resolve(rs)});
        return deferred;
    }
</script>